<?php

class  Application_Model_DbTable_CustomField extends Zend_Db_Table_Abstract
{
	protected $_name = 'custom_fields';

	public function getCustomField($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row)
		{
			throw new Exception("Could not find row $id");
		}
		return $row->toArray();
	}

	public function updateCustomField($id, $name, $type)
	{
		$data=array('name'=>$name,'type'=>$type);

		$this->update($data,'id =' . (int)$id);
	}

	public function removeCustomField($id)
	{
		$this->delete('id =' . (int)$id);
	}

	public function createCustomField($name, $type)
	{
		$data=array('name'=>$name , 'type'=>$type);
		$this->insert($data);
	}

}
?>